package cn.jhc.Adapter;

import java.util.ArrayList;

import com.example.shilehui.R;

import cn.jhc.Adapter.PublicUserEndowAdapter.DataWrapper;
import cn.jhc.bean.PublicUserImpression;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ListView;
import android.widget.TextView;

public class PublicUserImpressionListViewAdpter extends BaseAdapter {
	
	private LayoutInflater inflater;
	Context context;
	ArrayList<PublicUserImpression> publicUserImpressions;
	
	public PublicUserImpressionListViewAdpter(Context context,ArrayList<PublicUserImpression> publicUserImpressions) {
		this.context=context;
		this.publicUserImpressions=publicUserImpressions;
		inflater = (LayoutInflater) context
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);	
	}

	@Override
	public int getCount() {
		return publicUserImpressions.size();
	}

	@Override
	public Object getItem(int position) {
		return publicUserImpressions.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	TextView publicUserImpressionTextView;
	DataWrapper dataWrapper;
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		if(convertView==null){
			convertView=inflater.inflate(R.layout.public_user_impression_listview_item, null);
			publicUserImpressionTextView=(TextView) convertView.findViewById(R.id.public_user_impression_listview_item_impression);
			
			dataWrapper=new DataWrapper(publicUserImpressionTextView);
			
			convertView.setTag(dataWrapper);
		}else{
			dataWrapper=(DataWrapper) convertView.getTag();
		}
		dataWrapper.publicUserImpressionTextView.setText(publicUserImpressions.get(position).getImpression());
		
		return convertView;
	}
	
	public final class DataWrapper{
		public TextView publicUserImpressionTextView;

		public DataWrapper(TextView publicUserImpressionTextView) {
			
			this.publicUserImpressionTextView = publicUserImpressionTextView;
			
		}
	}

}
